#ifndef USR_CFG_H
#define USR_CFG_H


#define SUCCESS 		( 0)
#define FAILURE 		(-1)


#define JSON_CONFIG_PATH_MAX 				256									//配置文件最大路径长度
#define JSON_CONFIG_FILE					"./platform_8a2s1d_cfg.json"		//配置文件名称-与APP同目录
#define JSON_CONFIG_FILE_BACKUP				"./platform_8a2s1d_cfg.json.backup"	//配置备份文件名称-与APP同目录
#define JSON_CONFIG_FILE_MAX_LEN			102400								//配置文件不应该超过100KB
#define JSON_RESV_FILE_MAX_LEN				4096								//配置文件不应该超过4KB
#define SOCKET_CONFIG_FILE_HEAD_LEN			16									//配置文件头
#define SOCKET_CONFIG_FILE_OFFSET_OFFSET	8
#define SOCKET_CONFIG_FILE_LEN_OFFSET		12
#define SOCKET_RTC_TIME_LEN					19									//RTC数据长度例如2023-10-10 20:08:08


#define VDATA_SAVE_SD_PATH					"/mnt/sd/mmcblk1p2/vdata/"			//SD卡数据存储路径
#define VDATA_SAVE_EMMC_PATH				"/mnt/eMMC/mmcblk0p2/vdata/"		//eMMC数据存储路径
#define VDATA_SAVE_HDD1_PATH				"/mnt/hdd1/vdata/"					//磁盘1数据存储路径
#define VDATA_SAVE_HDD2_PATH				"/mnt/hdd2/vdata/"					//磁盘2数据存储路径
#define FILE_PATH_LEN						100									//所有文件路径长度不应超过
#define VDATA_FILE_PATH_LEN					60									//振动数据保存位置


#define SHA_VERIFY_DELAY					300					//每300秒校验一次
#define NET_CHECK_DELAY						5					//每5秒检查一下网络状态
#define WATCHDOG_INTERVAL_DELAY				10					//看门狗延时
#define PLUG_DET_DELAY						3					//插拔检测间隔时间
#define DISK_SIZE_CHECK_DELAY				15					//磁盘空间监测间隔
#define LM75A_TEMP_DELAY					10					//环境温度间隔时间
#define RS485_IDLE_DELAY					30					//环境温度间隔时间


#define SOCKET_SER							10					//线程连接池个数
#define SOCKET_REACCEPT_DELAY				5					//从新接收间隔时间
#define SOCKET_PORT_NUMBER 					6557
#define SOCKET_LISTEN_NUM  					5
#define SOCKET_RECV_BUF_SIZE				4096
#define SOCKET_US_DELAY						500
#define SOCKET_CFG_FILE_DELAY				3					//秒，不能频繁配置
#define SOCKET_TIMEOUT						10

#define DATA_FRAME_FILE_INFO_CODE			0x1001
#define DATA_FRAME_CHX_HEAD_CODE			0x2001
#define DATA_FRAME_EIGEN_DATA_CODE			0x3001
#define DATA_FRAME_RAW_DATA_CODE			0x4001
#define DATA_FRAME_RESV_DATA_CODE			0x5001

#define COMM_PROTOCOL_VERSION				"1.00"
#define JSON_CFG_PROTOCOL_VERSION			"1.00"


#define SOCKET_CLOSE_ERR					(-1)
#define SOCKET_TIMEOUT_ERR					(-2)
#define SOCKET_OTHERS_ERR					(-3)

#define ACC_CH_TOTAL						8					//加速度模拟通道数
#define SPD_CH_TOTAL						2					//转速通道数
#define BDS_CH_TOTAL						1					//BDS通道总数	

#define PING_PANG_FIFO_SIZE					8192				//FIFO大小
#define MAX_DATA_SAMPLING_FREQ				204800				//最大采样率
#define MAX_DATA_DURATION					10					//最大持续时间10秒
#define DEFAULT_DATA_SAMPLING_FREQ			102400				//默认采样率


#define VDATA_RAW_OFFSET					256
#define RAW_DATA_SIZE						2048000				//只有4MB空间，102400,10秒,204800,5秒,409600,2秒
#define RAW_DATA_FFT_LEN					51200				//保证输出频谱是25600点

#define PLATFORM_AMB_TEMP_THRD				(45.0f)
#define PLATFORM_START_TEMP_THRD			(50.0f)

#define ALGO_TD_DETREND_ORDER				1	

#define DEFAULT_FILE_FILL_CHAR				0x20 				//空格

#define CFG_FILE_HEAD_TYPEC0				"CFG0"
#define SAVE_FILE_HEAD_TYPEA0				"FIL0"
#define SAVE_FILE_HEAD_TYPEA1				"FIL1"
#define SAVE_FILE_HEAD_TYPEA2				"FIL2"
#define SAVE_FILE_HEAD_TYPEA5				"FIL5"
#define SAVE_FILE_HEAD_TYPEAA				"FILA"
#define SAVE_FILE_TAIL_CYHK					"CYHK"

#define SPI1_DEV_PATH 						"/dev/spidev1.0"
#define CMD_SPI_MODE 						SPI_MODE_0
#define CMD_SPI_BITS 						8
#define CMD_SPI_SPEED 						400000
#define CMD_SPI_DELAY 						50000 // us

#define AFE_SPI_FIRST_CMD_ERR				(-1)
#define AFE_SPI_FIRST_RTN_ERR				(-2)
#define AFE_SPI_SECOND_CMD_ERR				(-3)
#define AFE_SPI_SECOND_RTN_ERR				(-4)


#define BIT0								0
#define BIT1								1
#define BIT2								2
#define BIT3								3
#define BIT4								4
#define BIT5								5
#define BIT6								6
#define BIT7								7

#define SET_REG_BIT(VAL, BIT)				((VAL) |= (1 << (BIT)))
#define CLR_REG_BIT(VAL, BIT)				((VAL) &= ~(1 << (BIT)))
#define GET_REG_BIT(VAL, BIT)				((VAL) & (1 << (BIT)))

#define ARRAY_SIZE(a) 						(sizeof(a) / sizeof((a)[0]))

#define TCP_LOOK_FORWARD				"\nplease look forward to........\n"
#define TCP_SPLIT_LINE1					"\n***********************************************************\n"
#define TCP_SPLIT_LINE2					"*************************************************************\n"
#define TCP_COMPANY_INFO				"Beijing Chip Spring Measurement And Control Technology Studio\n"
#define TCP_TEL_CONTACT_INFO			"                                   TEL:185XXXX8510\n"
#define TCP_EMAIL_CONTACT_INFO			"                                  298046691@qq.com\n"
#define TCP_AUTHOR_OF_DEVICE			"                                       Wade3.Hou\n"

#endif

